package cn.itcast.account.web;

import cn.itcast.account.service.AccountService;
import cn.itcast.account.service.TCCAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("account")
public class AccountController {



    @Autowired
    private TCCAccountService tccAccountService;

    @PutMapping("/{userId}/{money}")
    public ResponseEntity<Void> deduct(@PathVariable("userId") String userId, @PathVariable("money") Integer money) throws InterruptedException {
//        accountService.deduct(userId, money);
        tccAccountService.deduct(userId,money);
        return ResponseEntity.noContent().build();
    }
}
